<template>
  <div>
    <div class="cost-main">
      <Title title="任务通知设置" style="font-size:16px" class="main-title"/>
      <!-- 需添加权限 -->
      <template >
        <el-button v-if="!showMobilePage" type="primary" plain size="small" class="btn-style" @click="addNotice">添加通知</el-button>
        <div v-else class="mobile-link-btn" @click="addNotice">添加通知</div>
      </template>
    </div>
    <noticeTable ref="noticeTableRef" @editData="editNotice" />
    <createNoticeDialog ref="createNoticeRef" @update="update" />
  </div>
</template>

<script>
// components
import noticeTable from './module/noticeTable';
import createNoticeDialog from './module/createNoticeDialog';
// api
import { hasRouteAuth } from '@/utils/permission';
import { mapState } from 'vuex';
import Title from '@/components/Title';

export default {
  components: { noticeTable, createNoticeDialog, Title },
  computed: {
    ...mapState({
      'showMobilePage': state => state.app.showMobilePage
    })
  },
  methods: {
    hasRouteAuth,
    addNotice() {
      this.$refs.createNoticeRef.openDialog();
    },
    editNotice(item) {
      this.$refs.createNoticeRef.openDialog(item);
    },
    update() {
      this.$refs.noticeTableRef.getListData(true);
    }
  }
};
</script>

<style lang="scss" scoped>
.btn-style {
  background:#fff;color:#406EFF;width:120px;padding:7px 0px;
}
.cost-main {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  .main-title {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    line-height: 14px;
    color: #141C3D;
    margin-right: 32px;
  }
}
</style>
